#include <bits/stdc++.h>
using namespace std;
const int N= 1e5+5;
int t,n,m,l,V,d[N],v[N],a[N],p[N];
int r[1000010];
bool b[N];
map<int,int>p2;
struct node{
    int id,l,r;
    node(int idd,int ll,int rr){
        id=idd,l=ll,r=rr;
    }
};

bool cmp(node x, node y){
    if(x.l!=y.l)return x.l>y.l;
    return x.r<y.r;
}
bool cmp2(node x, node y){
    if(x.l!=y.l)return x.l<y.l;
    return x.r<y.r;
}
int bfind(int L, int R, int x){
    while(L<R){
        int mid=(L+R)/2;
        if(r[mid]==x){
            R=mid;
        }else{
            L=mid+1;
        }
    }
    return L;
}
int b2find(int L, int R, int x){
    x++;
    while(L<R){
        int mid=(L+R+1)/2;
        if(r[mid]==x){
            L=mid;
        }else{
            R=mid-1;
        }
    }
    return L-1;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    while(t--){
        int ii=1,rr=1000001;
        vector<node>s;
        int cnt=0;
        memset(r,0,sizeof(r));
        memset(b,false,sizeof(b));
        cin >> n >> m >> l >> V;
        l++;
        for(int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
            d[i]++;
        }
        for(int i = 1; i <= m; i++) {
            cin >> p[i];
            p[i]++;
            r[p[i]]=1;
            p2[p[i]]=i;
        }
        for(int i = 2; i <= l; i++) {
            r[i]+=r[i-1];
        }
        for(int i = 1; i <= n; i++) {
            if(a[i]>0){
                if(v[i]>V){
                    if(r[l]-r[d[i]-1]>0){
                            rr=min(rr,d[i]);
                            cnt++;
                    }
                    continue;
                }
                if(v[i]==V){
                    if(r[l]-r[d[i]]>0){
                            rr=min(rr,d[i]);
                            cnt++;
                    }
                    continue;
                }
                double dis=(V*V-v[i]*v[i])*1.00/(2.00*a[i]);
                int lo=ceill(dis+1.0*d[i]);
                if(lo>l)continue;
                if(dis+1.0*d[i]==1.0*lo){
                    if(r[l]-r[lo]>0){
                        rr=min(rr,lo);
                        cnt++;
                    }
                    continue;
                }
                if(r[l]-r[lo-1]>0)cnt++;
            } else if(a[i]==0){
                if((v[i]>V)&&(r[l]-r[d[i]-1]>0))cnt++;
            } else {
                if(v[i]<=V)continue;
                double dis=(V*V-v[i]*v[i])*1.00/(2.00*a[i]);
                int lo=floor(dis+1.0*d[i]);
                if((dis+1.0*d[i]==1.0*lo)&&(lo<l)){
                    if(r[lo-1]-r[d[i]-1]>0){
                        cnt++;
                        s.push_back(node(ii,d[i],lo-1));
                        ii++;
                    }
                    continue;
                }
                lo=min(lo,l);
                if(r[lo]-r[d[i]-1]>0){
                    cnt++;
                    s.push_back(node(ii,d[i],lo));
                    ii++;
                }
            }
        }
        cout << cnt << " ";
        for(int i = 0; i < s.size(); i++) {
            s[i].r=bfind(s[i].l,s[i].r,r[s[i].r]);
            s[i].l=b2find(s[i].l-1,s[i].r,r[s[i].l]);
        }
        sort(s.begin(),s.end(),cmp);

        vector<node>tm;
        int R=s[0].r;
        for(int i = 1; i < s.size(); i++) {
            if(s[i].r>=R)continue;
            R=s[i].r;
            tm.push_back(s[i]);
        }
        sort(tm.begin(),tm.end(),cmp2);
        R=tm[0].r;
        int ans=1;
        for(int i = 1; i < tm.size(); i++) {
            if(tm[i].l>R){
                ans++;
                R=tm[i].r;
            }
        }
        if(R<rr)ans++;
        cout << m-ans << endl;
    }
    return 0;
}
